
package guice.boot.archive.container.pipeline;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import guice.boot.archive.exception.ArkRuntimeException;
import guice.boot.archive.spi.event.AfterFinishDeployEvent;
import guice.boot.archive.spi.pipeline.PipelineContext;
import guice.boot.archive.spi.pipeline.PipelineStage;
import guice.boot.archive.spi.service.biz.BizDeployService;
import guice.boot.archive.spi.service.event.EventService;


@Singleton
public class DeployBizStage implements PipelineStage {

    @Inject
    private BizDeployService bizDeployService;

    @Inject
    private EventService eventService;

    @Override
    public void process(PipelineContext pipelineContext) throws ArkRuntimeException {
        String[] args = pipelineContext.getLaunchCommand().getLaunchArgs();
        bizDeployService.deploy(args);
        eventService.sendEvent(new AfterFinishDeployEvent());
    }
}